package com.gzw.scm.base;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/12/25.
 */
public abstract class BaseFragment extends Fragment {
    protected View mView;
    /**
     * 屏幕的宽度�?高度、密�?
     */
    protected List<AsyncTask<Void, Void, Boolean>> mAsyncTasks = new ArrayList<AsyncTask<Void, Void, Boolean>>();




    public BaseFragment() {
        super();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mView = setContentView(inflater, container, savedInstanceState);
        initViews();
        initEvents();
        initData();
        return mView;
    }

    protected abstract View setContentView(LayoutInflater inflater, ViewGroup container,
                                           Bundle savedInstanceState);

    protected abstract void initViews();

    protected abstract void initEvents();

    public View findViewById(int id) {
        return mView.findViewById(id);
    }

    protected abstract void initData();

    protected boolean isNull(EditText et) {
        boolean b = false;
        if (isNull(et.getText().toString())) {
            b = true;
        }
        return b;
    }

    protected boolean isNull(TextView tv) {
        boolean b = false;
        if (isNull(tv.getText().toString())) {
            b = true;
        }
        return b;
    }

    protected boolean isNull(String str) {
        boolean b = false;
        if (str.trim() == null
                || str.trim().length() == 0) {
            b = true;
        }
        return b;
    }

}
